// Author: Domien Nowicki

#include "TextureItemDelegate.h"

TextureItemDelegate::TextureItemDelegate(QObject *parent): QItemDelegate(parent)
{
}

TextureItemDelegate::~TextureItemDelegate()
{
}

void TextureItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	// Adjust size for the grid
	QStyleOptionViewItem opt = option;
	opt.rect.adjust(0, 0, -1, -1);
	QItemDelegate::paint(painter, opt, index);

	// Draw grid
	QPen pen = painter->pen();
	painter->setPen(option.palette.color(QPalette::Mid));
	painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
	painter->drawLine(option.rect.topRight(), option.rect.bottomRight());
	painter->setPen(pen);
}

QSize TextureItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	// Because we draw the grid ourselves
	return QItemDelegate::sizeHint(option, index) + QSize(1, 1);
}
